package cn.tedu.review;

import java.util.Arrays;

/*本类用于测试数组工具类Arrays*/
public class TestArray2 {
    public static void main(String[] args) {
//        copyOf(被复制的数组名，新数组的长度)
        int[] from = {1,2,3,4,5};
        int[] to = Arrays.copyOf(from,5);
        System.out.println(Arrays.toString(to));
//        数组的扩容
        int[] to2 = Arrays.copyOf(from,15);
        System.out.println(Arrays.toString(to2));
//        数组的缩容
        int[] to1 =Arrays.copyOf(from,2);
        System.out.println(Arrays.toString(to1));
        System.out.println(Arrays.toString(from));
    }
}
